# 猜数字游戏开发

import random

print("Let's try if you can guess the lucky number!")
n = input("Whether to enter the game (please enter Yes or No)")
s = 5000

while n == 'Yes':
    a = random.randint(0,100)
    m = 'Y'
    while m == 'Y':
        x = int(input("please input a number(0~100):"))
        if a > x and 0 < x <= 100 :
            print("You guessed too small~")
            s = s - 500
        elif a < x and 0 < x <= 100 :
            print("You guessed too big~")
            s = s - 500
        elif a == x :
            print("Congratulations on guessing correctly. The lucky number for this round is {}".format(a))
            s = s + 3000
            m = 'N'
            break
        else :
            print("Please enter a number within the range of 0 to 100!")
            s = s - 500
        if s < 500 :
            print("You don't have enough coins!")
            m = 'N'
            break
        m = input("Your gold coin count is {} ~ Do you want to continue guessing the lucky numbers for this game?(Y/N)".format(s))
    if s < 500 :
        n = 'No'
        break
    n = input("Your gold coin count is {} ~ Do you want to continue this game(Yes/No)".format(s))

print("Your gold coin count is {} ~ Game over, welcome to play again next time~".format(s))
